import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import registerServiceWorker from './registerServiceWorker';
import { createStore, applyMiddleware, compose } from 'redux';
import thunk from 'redux-thunk';
import { Provider } from 'react-redux';
import { BrowserRouter, Route, Switch, Redirect } from 'react-router-dom';

import 'bootstrap/dist/css/bootstrap.min.css'
import './config/config';
import 'jquery/dist/jquery.min'
import 'bootstrap/dist/js/bootstrap.min'


import combineReducers from './redux/reducer';
import { RouterList } from './router/routers';
console.log(RouterList)
/*  
      mapping   完全匹配   组件 或者 标签
<Route path="/" exact   component={App}></Route>*/

//创建 store 数据流 参数包括 合并后的combineReducers 中间件
const store = createStore(combineReducers,
    //compose聚合函数，整合浏览器开发工具
    compose(
        applyMiddleware(thunk)
        // window.devToolsExtensions ? window.devToolsExtensions() : f => f
    )
);
ReactDOM.render(
    <Provider store={store}>
        <BrowserRouter>
            <Switch>
                {RouterList.map((item, key) => {
                    console.log(item);
                    return <Route path={item.path} key={key} exact component={item.component}></Route>;
                })}
            </Switch>
        </BrowserRouter>
    </Provider>,
    document.getElementById('root'));
registerServiceWorker();
